home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-08 | 1.6 KB | 61 lines | [TEXT/YERK] |
- \ optional definitions for floating point
- \ 1/24/86 gdc Moved f0=, f0<, and f0> from fpcode
- \ 12/25/92 rfl added fmax,fmin
- \ 5/08/93 rfl added arcsin, arccos
-
- \ Some useful constants =============================================== \
-
- 1.0 fcon 1.0
- 0.0 fcon 0.0
- 1.0 arctan 4.0 f* fcon pi
- 1.0 exp fcon e
- 10.0 ln fcon ln(10)
-
- \ ===================================================================== \
-
- ( -- bool )
- \ ( x -F- ) Zero-equal-to logical operator for floats
- : f0= 0.0 f= ;
-
- ( -- bool )
- \ ( x -F- ) Zero-Less-than logical operator for floats
- : f0< 0.0 f< ;
-
- ( -- bool )
- \ ( x -F- ) Zero-greater-than logical operator for floats
- : f0> 0.0 f> ;
-
- \ ===================================================================== \
-
- : 1/x 1.0 swap f/ ;
-
- \ ( x -- log(x) ) log base 10 of x
- : log ln ln(10) f/ ;
-
- \ ( x -- antilog(x) ) antilog ( 10^x ) of x
- : antilog ln(10) f* exp ;
-
- \ ( x -- cot(x) ) cotangent of x
- : cot tan 1/x ;
-
- \ ( deg -F- rad ) converts degrees to radians
- : deg2Rad PI f* 180. f/ ;
-
- \ ( rad -F- deg ) converts radians to degrees
- : rad2Deg 180. f* PI f/ ;
-
- : fmax ( f1 f2 -- fmax) f2dup f> IF fdrop ELSE swap fdrop THEN ;
- : fmin ( f1 f2 -- fmin) f2dup f< IF fdrop ELSE swap fdrop THEN ;
-
- : arcsin { %x -- f }
- %x fabs .3 f>=
- IF %x %x 1. f+ 1. %x f- f* sqrt f/ arctan
- ELSE %x fabs f0>
- IF %x 1. %x %x f* f- sqrt f/ arctan
- ELSE 0.
- THEN
- THEN ;
-
- : arccos { %x -- f }
- 1. %x f- 1. %x f+ f/ sqrt arctan 2. f* ;
-